package cn.geapi.core.service.impl;

import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.geapi.core.dao.IUserDao;
import cn.geapi.core.datasource.annotation.DataSource;
import cn.geapi.core.domain.bean.UserBean;
import cn.geapi.core.domain.entity.UserEntity;
import cn.geapi.core.service.IUserService;
import cn.geapi.core.util.Constraints;
import cn.geapi.core.util.EntityBeanConvert;

@DataSource(name = DataSource.main)
@Service
public class UserServiceImpl implements IUserService {
	@Autowired
	private IUserDao userDao;

	public UserBean findUser(String account, String password) throws Exception {
		UserEntity userEntity = userDao.selectOne(new UserEntity(account,
				DigestUtils.md5Hex(password), Constraints.DATA_NOMAL));
		return EntityBeanConvert.convert(userEntity, UserBean.class);
	}
}
